import type {
  mobileCodeUpData,
  mobileCodeDownData,
  signInUpData,
  signInDownData,
  quickLoginUpData,
  quickLoginDownData,
  loginUpData,
  loginDownData,
  mobileLoginUpData,
  WXFastType,
} from '@/types/login'
import { http } from '@/utils/http'
/**
 * * 验证码
 * @param data
 * @returns
 */
export const getMobileCodeApi = (data: mobileCodeUpData) => {
  return http<mobileCodeDownData>({
    method: 'GET',
    url: '/client/login/captcha',
    data,
  })
}
/**
 * * 快捷登录
 * @param data
 * @returns
 */
export const postQuickLoginApi = (data: quickLoginUpData) => {
  return http<any>({
    method: 'POST',
    url: '/auth/login/wechat/applet',
    data,
  })
}

/**
 * * 用户注册
 * @param data
 * @returns
 */
export const postSignInApi = (data: signInUpData) => {
  return http<any>({
    method: 'POST',
    url: '/auth/register/wechat/applet',
    data,
  })
}
/**
 * * postLoginApi 用户登录接口  login/wechat/applet
 */

export const postLoginApi = (data: loginUpData) => {
  return http<any>({
    method: 'POST',
    url: '/auth/login/wechat/applet',
    data,
  })
}
/**
 * *  手机号、验证码、登陆接口  	/client/login/mobileCaptcha
 */
export const postMobileLoginApi = (data: mobileLoginUpData) => {
  return http<any>({
    method: 'POST',
    url: '/client/login/mobileCaptcha',
    data,
  })
}

/**
 * 调用微信手机号快速验证组件触发接口
 * @param  weChatCode: string
 * @param   openId: string
 * @param   unionId: string
 * @param   invitationClientId?: string
 */
export const getWXFastApi = (data: WXFastType) => {
  return http<any>({
    method: 'POST',
    url: '/client/login/authMobile',
    data,
  })
}

/**
 *
 * * logoutUserApi 用户注销接口
 * @returns
 */
export const logoutUserApi = (data?: any) => {
  return http<any>({
    method: 'POST',
    url: '/auth/user/account/account_end/apply/confirm',
    data,
  })
}

/**
 * *  判断用户是否第一次登录
 * @param weChatCode 微信的code
 */
export const isUserOneLoginApi = (data: {
  weChatCode: string
  invitationClientId?: string
  enterprise?: number
  cityName?: string
}) => {
  return http<any>({
    method: 'POST',
    url: '/client/login',
    data,
  })
}
